# -*- coding: utf-8 -*-            
# @Author : chenliang
# @Time : 2023/12/19 14:39

from selenium.webdriver.common.by import By
from datetime import datetime

class  ResourcePackagesLocator:

    # 公共方法
    # 等待转菊花
    wait_for_pay = (By.CSS_SELECTOR,'[class="antd4-spin-dot antd4-spin-dot-spin"]')

    # Resource Packages菜单
    resource_packages_tab = (By.CSS_SELECTOR, '[path="/work_bench/resource/packages"]')
    # 打开Resource Packages菜单成功展示元素
    resource_packages_seccess = (By.XPATH, '(//div[@class="antd4-space-item"])[1]/div')
    # 选择日期组建

    #搜索条件resource package id
    resource_package_id = (By.ID,'resourcePackageId')
    #查询按钮
    resource_package_search = (By.CSS_SELECTOR,'[class ="antd4-btn antd4-btn-primary"]')
    #Total items
    resource_package_total_items = (By.CSS_SELECTOR,'[class="antd4-pagination-total-text"]')
    #reset按钮
    resource_package_reset = (By.CSS_SELECTOR,'[class="antd4-btn antd4-btn-default"]')
    #时间选择框
    resource_package_time = (By.CSS_SELECTOR,'[class="antd4-picker-input antd4-picker-input-active"]')
    #选择开始时间title="2023-12-25"
    now = datetime.now()
    now_str = now.strftime('%Y-%m-%d')
    now_str1 = now.strftime('%d-%m-%Y')
    content = '[title="'+now_str+'"]'
    resource_package_select_time = (By.CSS_SELECTOR,content)
    # 查询列表
    resource_package_select_list = (By.CSS_SELECTOR,'class="cre-table-nowrap"')
    # 时间选择框-开始时间
    resource_package_time_begin = (By.CSS_SELECTOR,'[placeholder="Effective Start Date"]')
    # 时间选择框-结束时间
    resource_package_time_end = (By.CSS_SELECTOR, '[placeholder="Effective End Date"]')

    #点击创建资源包按钮 class="antd4-btn antd4-btn-primary antd4-dropdown-trigger"
    resource_package_create = (By.CSS_SELECTOR,'[class="antd4-btn antd4-btn-primary antd4-dropdown-trigger"]')
    #点击创建 create_oss_resource
    test = (By.LINK_TEXT,'Create OSS Resource Package')
    # 移动到创建按钮
    move_create_resource_package = (By.XPATH,'//span[text()="Create Resource Package "]')
    # 链接地址
    def lick_detil(self, str):
        str_old = '//a[text()="'
        str_new = str_old + str + '"]'
        return (By.XPATH, str_new)

    #创建资源包勾选条款
    create_resource_package_terms = (By.XPATH,'(//span[@class="antd4-checkbox-inner"])[3]')


    #buy_now按钮  class="antd4-btn antd4-btn-primary"
    create_resource_buy_now = (By.CSS_SELECTOR, '[class="antd4-btn antd4-btn-primary"]')
    #pay class="antd4-btn antd4-btn-primary footerBtn___1_1RN"
    create_resource_pay = (By.CSS_SELECTOR, '[class="antd4-btn antd4-btn-primary footerBtn___1_1RN"]')

    #创建资源包 后check_order  class="antd4-btn antd4-btn-default"
    create_resource_check_order = (By.CSS_SELECTOR, '[class="antd4-btn antd4-btn-default"]')
    #创建资源包后 open_console class="antd4-btn antd4-btn-primary"
    create_resource_open_console = (By.CSS_SELECTOR, '[open_console class="antd4-btn antd4-btn-primary"]')

    # resource_packages 查询列表第一条数据的 Enable Auto-renewal 按钮
    # //*[@id="rc-tabs-0-panel-Overview"]/div/div/div/div/div/div/div/table/tbody/tr[2]/td[12]/button
    create_resourc_num1 = (By.XPATH,'(//*[@class="antd4-table-tbody"]//button[@type="button" and @role="switch"])[1]')

    # 滚动条
    test1 = (By.CSS_SELECTOR,'[class="antd4-table-content"]')
    #test1 = (By.CSS_SELECTOR,'[style="width: auto; min-width: 100%; table-layout: fixed;"]')

    # class="antd4-btn antd4-btn-primary"
    # 启动自动续订
    enable_auto = (By.XPATH,'//div[2]/div/div[2]/div[3]/button[2]')

    # class="antd4-switch-inner"
    # 判断自动续订是否开启
    if_enable_auto = (By.CSS_SELECTOR,'[class="antd4-switch-inner"]')